<?php if ( ! defined('FWORK')) exit('No direct script access allowed');
/******************************************************************************
 * Project  : TWD:CMF
 * Author   : Mark LaDoux < mark@haktstudios.com >
 * WWW      : http://haktstudios.com/
 * Copyright: (c) 2009 HaKT Studios
 ******************************************************************************/

/* Constant Pasthrough Debug Check *

echo PHP_OS.'<br />'.EXT.'<br />'.SROOT.'<br />'.SELF.'<br />'.FWORK.'<br />'.APP.'<br />'.TWD_VERSION;

/**/

function check_rw($file)
{

  // if server isn't running windows and isn't in safe mode
  // we take the easy way out

  if(PHP_OS != 'WINNT' AND @ini_get('safe_mode') == FALSE)
  {

    return is_writable($file);

  }

  // Otherwise we will attempt to write a file and read it to see if
  // everything is writable.

  if(is_dir($file))
  {

    // rtrim to remove any trailing slashes if they are present
    // than add trailing slash that way we ensure we always have a
    // trailing slash, but never a trailing doubleslash.
    $file = rtrim($file, '/').'/'.md5(rand(1,100));

    if($f = @fopen($file, FOPEN_WRITE_CREATE) === FALSE)
    {

      return FALSE;

    }
    fclose($f);
    @chmod($file, DIR_WRITE_MODE);
    @unlink($file);

  }
  elseif (($f = @fopen($file, FOPEN_WRITE_CREATE)) === FALSE)
	{

		return FALSE;

	}
	fclose($f);
	return TRUE;

}

/* EOF framwork/glue/common.php */
